import request from '@/config/axios'

export interface EvalEvaluatorQualificationVO {
  id?: number
  userId: number
  evaluatorName?: string
  evaluatorCode?: string
  professionCodes: string
  skillLevels: string
  certificateNumber: string
  certificateIssuer: string
  certificateDate: string
  validUntil?: string
  specialties?: string
  maxWorkload?: number
  qualificationStatus: number
  qualificationComments?: string
  createTime?: Date
}

export interface EvalEvaluatorQualificationPageReqVO extends PageParam {
  userId?: number
  evaluatorName?: string
  evaluatorCode?: string
  professionCodes?: string
  certificateNumber?: string
  qualificationStatus?: number
  certificateDate?: string[]
  createTime?: Date[]
}



// 查询考评员资质分页
export const getEvaluatorQualificationPage = (params: EvalEvaluatorQualificationPageReqVO) => {
  return request.get({ url: '/eval/evaluator-qualification/page', params })
}

// 查询考评员资质详情
export const getEvaluatorQualification = (id: number) => {
  return request.get({ url: '/eval/evaluator-qualification/get?id=' + id })
}

// 新增考评员资质
export const createEvaluatorQualification = (data: EvalEvaluatorQualificationVO) => {
  return request.post({ url: '/eval/evaluator-qualification/create', data })
}

// 从用户批量创建考评员资质
export const batchCreateEvaluatorQualificationFromUsers = (data: any) => {
  return request.post({ url: '/eval/evaluator-qualification/batch-create-from-users', data })
}

// 修改考评员资质
export const updateEvaluatorQualification = (data: EvalEvaluatorQualificationVO) => {
  return request.put({ url: '/eval/evaluator-qualification/update', data })
}

// 删除考评员资质
export const deleteEvaluatorQualification = (id: number) => {
  return request.delete({ url: '/eval/evaluator-qualification/delete?id=' + id })
}

// 导出考评员资质
export const exportEvaluatorQualification = (params: EvalEvaluatorQualificationPageReqVO) => {
  return request.download({ url: '/eval/evaluator-qualification/export-excel', params })
}

// 根据职业代码获得考评员列表
export const getEvaluatorListByProfessionCode = (professionCode: string) => {
  return request.get({ url: '/eval/evaluator-qualification/list-by-profession?professionCode=' + professionCode })
}

// 根据资质等级获得考评员列表
export const getEvaluatorListByQualificationLevel = (qualificationLevel: string) => {
  return request.get({ url: '/eval/evaluator-qualification/list-by-level?qualificationLevel=' + qualificationLevel })
}

// 根据状态获得考评员列表
export const getEvaluatorListByStatus = (qualificationStatus: number) => {
  return request.get({ url: '/eval/evaluator-qualification/list-by-status?qualificationStatus=' + qualificationStatus })
}

// 获取有效的考评员列表（用于计划选择）
export const getValidEvaluatorList = () => {
  return request.get({ url: '/eval/evaluator-qualification/list-by-status?qualificationStatus=1' })
}



// 启用考评员资质
export const enableEvaluatorQualification = (id: number) => {
  return request.put({ url: '/eval/evaluator-qualification/enable?id=' + id })
}

// 禁用考评员资质
export const disableEvaluatorQualification = (id: number) => {
  return request.put({ url: '/eval/evaluator-qualification/disable?id=' + id })
}

// 续期考评员资质
export const renewEvaluatorQualification = (id: number, expiryDate: string) => {
  return request.put({ url: '/eval/evaluator-qualification/renew', data: { id, expiryDate } })
}

// 获取考评员统计信息
export const getEvaluatorStatistics = () => {
  return request.get({ url: '/eval/evaluator-qualification/statistics' })
}
